{/* import CustomNav from "@/components/CustomNav"; */}
{/* <CustomNav
title="搜索"
navBgColor="#fff"
titleColor="#000"
isShowBack
/> */}
// getNavHeight = navHeight => {
// 	this.setState({
// 		navHeight: navHeight
// 	});
// };
import { Component, Fragment } from "react";
import Taro, { getCurrentInstance } from "@/newTaro";
import { View } from "@tarojs/components";

import "./index.scss";

/**
 * 组件说明
 * @method 自定义导航栏
 * @param{String} title 导航栏标题
 * @param{Boolean} isShowBack 是否展示返回按钮
 * @param{Boolean} isOpacity 是否为透明模式
 * @param{Boolean} isLight 透明模式下内容是否为白色
 * @param{Function} getNavHeight 通知父级自定义导航栏高度的回调方法
 * @param{Function} customBack 自定义返回按钮事件
 * @param{String} navBgColor 导航栏背景颜色
 * @param{String} titleColor 标题颜色
 */
// @connect(state => ({
// 	statusBarHeight: state.systemInfos.statusBarHeight
// }))
class CustomNav extends Component {
	static defaultProps = {
		isShowBack: true
	};
	constructor(props) {
		super(props);
		this.handleBack = this.handleBack.bind(this);
		this.state = {
		};
	}
	componentDidMount() {	
	}

	handleBack() {
		const { customBack } = this.props;
		if (customBack) {
			customBack();
		} else {
			Taro.navigateBack();
		}
	}
	goBackHome = () => {
		Taro.switchTab({
			url: "/pages/index/index"
		});
	};
	navBackIconView() {
		const showHomeIcon = Taro.getCurrentPages().length === 1 ? true : false;
		const { isOpacity, isLight } = this.props;
		const isTitleLight = isOpacity && isLight;
		return (
			<Fragment>
				{showHomeIcon ? (
					<View onClick={this.goBackHome} className='nav-icon-back'>
						{/* todo */}
						{/* <NiuIcon name='back' size='24' color={isTitleLight ? "#fff" : "#000"} /> */}
					</View>
				) : (
					<View onClick={this.handleBack} className='nav-icon-back'>
						{/* todo */}
						{/* <NiuIcon name='back' size='24' color={isTitleLight ? "#fff" : "#000"} /> */}
					</View>
				)}
			</Fragment>
		);
	}

	render() {
		const { title, isOpacity, isShowBack, isLight, navBgColor, titleColor } = this.props; //statusBarHeight todo
		const {  } = this.state;
		const isTitleLight = isOpacity && isLight;
		const navBarStyle = {
			paddingTop: 44 + "px",//statusBarHeight todo
			backgroundColor: isOpacity ? "transparent" : navBgColor ? navBgColor : "#fff"
		};
		const titleStyle = { color: isTitleLight ? "#fff" : titleColor ? titleColor : "#000" };
		const isH5 = process.env.TARO_ENV === "h5";
		return (
			<Fragment>
				{isH5 ? null : (
					<View className='nav-bar' style={navBarStyle}>
						<View className='nav-bar-inner'>
							{ isShowBack ? this.navBackIconView() : null}
							<View class='title' style={titleStyle}>
								{title}
							</View>
						</View>
					</View>
				)}
			</Fragment>
		);
	}
}

export default CustomNav;
